Inference.ts: scrub ANTHROPIC_BASE_URL alongside API key/token in nested claude spawn#1441
Open
jshingler wants to merge 1 commit into
Open
Conversation
The nested-claude subprocess spawn deletes ANTHROPIC_API_KEY and ANTHROPIC_AUTH_TOKEN from the child env to force subscription billing, but never cleared ANTHROPIC_BASE_URL. If a user has that set to a local proxy (e.g. a LiteLLM gateway used for cost tracking/observability), every nested inference() call -- including the mode/tier classifier that PromptProcessing.hook.ts invokes on every prompt, and the Advisor calls in VERIFY -- kept targeting that proxy, but now with zero valid Anthropic credentials in env. The proxy correctly rejects with 401, the subprocess retries, and the call eats its full timeout before giving up. Observed impact: with ANTHROPIC_BASE_URL set, the mode classifier failed on every single message (Timeout after 25000ms), forcing the fail-safe path instead of real classification, plus a steady stream of 401s in the proxy's logs from the retries. Fixes the reported bug.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1440.
Bug
Inference.ts's nestedclaude --printsubprocess spawn deletesANTHROPIC_API_KEYandANTHROPIC_AUTH_TOKENfrom the child environment to force subscription billing (per the existing comment on that block), but never clearedANTHROPIC_BASE_URL.If a user has
ANTHROPIC_BASE_URLset to a local proxy (e.g. a LiteLLM gateway used for cost tracking/observability — a documented pattern), every nestedinference()call — including the mode/tier classifierPromptProcessing.hook.tsinvokes on every prompt, and the Advisor calls in the Algorithm's VERIFY phase — kept targeting that proxy, but now with zero valid Anthropic credentials in env (both keys just stripped). The proxy correctly rejects with401 Unauthorized, the subprocess retries, and the call burns its full timeout before giving up.Observed impact: with
ANTHROPIC_BASE_URLset, the mode classifier failed on every single message (Timeout after 25000ms), forcing the fail-safe path (SOURCE: fail-safe, default tier) instead of real classification — plus a steady stream of 401s in the proxy's logs from the retries.Fix
One-line addition scrubbing
ANTHROPIC_BASE_URLalongside the existing two deletes, so nested subscription-billed calls always go straight to Anthropic's real API regardless of what the parent shell has configured for interactive proxy routing.Testing
Verified against a live setup with
ANTHROPIC_BASE_URLpointed at a local LiteLLM proxy: before the fix, every classifier invocation timed out with repeated 401s in the proxy logs; the fix routes nested calls around the proxy as intended.